<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<link rel="stylesheet" type="text/css" href="css/manager.css">

  </head>
  
  <body>
  	<h1 style="margin-bottom:0px;">文章列表</h1>
  	<hr style="border:1px dashed #AAA;"/>
  	<input type="button" value="返 回" onclick="history.back();">
  	<input type="button" value="前 进" onclick="history.forward();">
  	<input type="button" value="刷 新" onclick="location.reload();">
  	<div style="height:10px;"></div>
    <table border="1" cellpadding="5" cellspacing="0">
    	<tr bgcolor="#EEEEEE"><td>编号</td><td>ID</td><td>标题</td><td>内容</td><td>来源</td><td>作者</td><td>类型</td><td>时间</td><td>操作</td></tr>
    	<c:forEach items="${pv.records}" var="article" varStatus="vs">
    	<tr>
    		<td width="40">${vs.count}</td>
    		<td width="40">${article.id}</td>
    		<td width="160">${article.title}</td>
    		<td width="260">
    			<c:out value="${fn:substring(article.content,0,17)}"></c:out>
    			<c:if test="${fn:length(article.content) > 17}">...</c:if>
    		</td>
    		<td width="100">${article.comefrom}</td>
    		<td width="100">${article.author}</td>
    		<td width="80">${articleType[article.atype]}</td>
    		<td width="140">${fn:substring(article.atime,0,19)}</td>
    		<td width="220">
    			<a href="comment.do?method=getCommentByTid&tid=${article.id}&ctype=1" title="共有${article.commentCount}条评论">评论(${article.commentCount})</a>|
    			<a href="javascript:location.href='article.do?method=getById&id=${article.id}&detail=1';">详细</a>|
    			<a href="javascript:location.href='article.do?method=getById&methodName=modifyArticle&id=${article.id}';">修改</a>|
    			<a href="javascript:del('${article.id}');">删除</a>
    		</td>
    	</tr>
    	</c:forEach>
    	<c:if test="${fn:length(pv.records)==0}">
    		<tr>
    			<td colspan="9" width="600px">未找到文章记录！</td>
    		</tr>
    	</c:if>
    	
    </table>
    <%@ include file="../../pages/share/pager.jsp" %>
  </body>
  <script type="text/javascript" src="js/javer.js"></script>
  <script type="text/javascript">
  	function del(id) {
  		if (confirm("你确定要删除这条记录？")) {
  			$.get("comm.do?method=deleteById&tableName=article&id=" + id, function() {
  				alert("删除记录成功，系统将自动刷新！");
  				location.reload();
  			});
  		}
  	}
  	function topage(pageNo) {
  		location.href="article.do?method=listArticleByPage&pageNo=" + pageNo;
  	}
  </script>
</html>
